<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>快递之家-用户页面</title>
</head>
<link rel="icon" href="data:;base64,=">
<link rel="stylesheet" href="/static/layui/layui/css/layui.css">
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div th:replace="head::UserNavHeader"></div>
    <div th:replace="menu::UserNavMenu"></div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <fieldset class="layui-elem-field layui-field-title">
            <legend>快递单信息</legend>
        </fieldset>
        <form class="layui-form" id="hdForm" lay-filter="userForm">
            <div class="layui-form-item">
                <label class="layui-form-label">寄件人</label>
                <div class="layui-input-inline">
                    <input type="hidden" id="kid" name="kid" th:value="${session.user.getKid()}">
                    <input type="text" name="hdkhn" required lay-verify="required" placeholder="请输入寄件人" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">寄件人电话号码</label>
                <div class="layui-input-inline">
                    <input type="text" name="hdkhtelephone" required lay-verify="required" placeholder="请输入寄件人电话号码" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">寄件人住址</label>
                <div class="layui-input-inline">
                    <input type="text" name="hdkhadress" required lay-verify="required" placeholder="请输入寄件人住址" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">收件人</label>
                <div class="layui-input-inline">
                    <input type="text" name="hdshrn" required lay-verify="required" placeholder="请输入收件人" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">收件人电话号码</label>
                <div class="layui-input-inline">
                    <input type="text" name="hdshrtelephone" required lay-verify="required" placeholder="请输入收件人电话号码" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">收件人住址</label>
                <div class="layui-input-inline">
                    <input type="text" name="hdshradress" required lay-verify="required" placeholder="请输入收件人住址" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>
<!--            <div class="layui-form-item">
                <label class="layui-form-label">快递种类</label>
                <div class="layui-input-inline">
                    <input type="text" name="hdhwkind" required lay-verify="required" placeholder="请输入快递种类" autocomplete="on" class="layui-input" style="width:200px">
                </div>
            </div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">快递种类</label>
                <div class="layui-input-inline">
                    <select name="hdhwkind" lay-verify="required">
                        <option value=""></option>
                        <option value="百世快递">百世快递</option>
                        <option value="顺丰快递">顺丰快递</option>
                        <option value="韵达快递">韵达快递</option>
                        <option value="邮政快递">邮政快递</option>
                        <option value="中通快递">中通快递</option>
                        <option value="圆通快递">圆通快递</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">快递重量</label>
                <div class="layui-input-block">
                    <input type="text" name="hdhwweight" required  lay-verify="required" placeholder="请输入快递重量" autocomplete="on" class="layui-input" id="eidt_pid" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="hdinfo" required  lay-verify="required" placeholder="请输入备注" autocomplete="on" class="layui-input" id="eidt_pid" style="width:200px">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <button type="button" lay-submit="editForm" class="layui-btn layui-btn-normal" lay-filter="sub">确定下单</button>
                </div>
                <div class="layui-input-inline">
                    <button type="reset"  class="layui-btn layui-btn-normal">取消下单</button>
                </div>
            </div> 
        </form>
    </div>
    <div th:replace="bottom::NavBottom"></div>
</div>
</body>
<script src="/static/layui/layui/layui.all.js"></script>
<script>
    layui.use(['jquery','element','form','table','layer','laydate'], function(){
        var $ = layui.jquery;
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var kid = $("#kid").val();

        form.on('submit(sub)', function(data){
            $.ajax({
                url:"/hd/save",
                dataType:"json",   //返回格式为json
                async:true,
                data:data.field,    //参数值
                type:"POST",   //请求方式
                success:function(req){
                    //请求成功时处理
                    //console.log(req);
                    if(req.code === 0){
                        layer.msg('下单成功', {icon: 1});
                    }else{
                        layer.msg('下单失败 '+req.msg, {icon: 5});
                    }
                },
                error:function(){
                    //请求出错处理
                    layer.msg('下单失败', {icon: 5});
                }
            });
        });
        /*$.ajax({
            url:"/hd/save",
            dataType:"json",   //返回格式为json
            async:true,
            data: data,    //参数值
            type:"GET",   //请求方式
            success:function(req){
                //请求成功时处理
                if(req.code === 0){
                    form.val("hdForm",req.data);
                    form.render(); //更新全部
                }
            },
            error:function(){
                //请求出错处理
                layer.msg('发送失败', {icon: 5});
            }
        });*/

    });
</script>
</html>